package com.test.controller;

import com.commons.entity.Book;
import com.commons.entity.ResultFul;
import com.commons.entity.User;
import com.test.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    UserService userService;

    /**
     *  用于直接查询用户信息的接口
     * @param sid
     * @return
     */
    @GetMapping("{sid}")
    public ResultFul findUserById(@PathVariable("sid") Integer sid){
        return userService.findBySid(sid);
    }

    /**
     *  用于间接 接口内部调用去获取用户信息的接口
     * @param sid
     * @return
     */
    @GetMapping("api/{sid}")
    public User apiFindUserById(@PathVariable("sid") Integer sid){
        return (User) userService.findBySid(sid).getData();
    }
}
